<?php

function get_users_list(){
global $_CONFIG;

	$result = mysql_query("
	SELECT *
	FROM ". $_CONFIG['table_users'] ."
  WHERE temp='0'
	");
	$data = array();
	while($tmp = mysql_fetch_assoc($result)){
		array_push($data, $tmp);
	};
	
	return $data;
}

function user_get_id($user){
global $_CONFIG;

	return mysql_result(mysql_query("
	SELECT id
	FROM ". $_CONFIG['table_users'] ."
	WHERE username='".$user['username']."' and password='".$user['password']."'
	"), 0, 'id');
}

//FROM CONFIG.php

function check_username($value){
	global $_CONFIG;
	
	$value = trim($value);
	if($value == "")
		return "The field cannot be empty";
	$query = mysql_query("
	SELECT id
	FROM ".$_CONFIG['table_users']."
	WHERE username='".$value."'");
	if(mysql_num_rows($query) != 0)
		return "Username already registered";
	
	return true;
}

function check_global($value){
	global $_CONFIG;
	
	$value = trim($value);
	if($value == "")
		return "The field cannot be empty";
	
	return true;
}
?>